const express = require('express');
const router = express.Router();
const userController = require('../controllers/userController');
const { authenticateToken } = require('../middleware/auth');
const { validateRegister, validateLogin } = require('../middleware/validation');

// 公开路由
router.post('/register', validateRegister, userController.register);
router.post('/login', validateLogin, userController.login);

// 管理员登录
router.post('/admin/login', userController.adminLogin);

// 需要认证的路由
router.get('/info', authenticateToken, userController.getUserInfo);
router.put('/info', authenticateToken, userController.updateUserInfo);
router.post('/change-password', authenticateToken, userController.changePassword);
router.post('/logout', userController.logout);

module.exports = router;